using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for ControlProviders
/// </summary>
public class ControlProviders
{
	public ControlProviders()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    private string errorMessage = "";
    public string ErrorMessage
    {
        set { errorMessage = value; }
        get { return errorMessage; }
    }
    public int FillRecruiterAccount(DataList DataList1, int startRecord, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SQLServerProviders cls = new SQLServerProviders(connectionString);
            DataTable dataTable = cls.GetDataTable("select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts", CommandType.Text, startRecord, maxRecord);
            totalRecord = dataTable.Rows.Count;
            DataList1.DataKeyField = "RecruiterID";
            DataList1.DataSource = dataTable;
            DataList1.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage=ex.Message ;
        }
        return totalRecord;
    }
    public int FillRecruiterAccount(DataList DataList1,  int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string querySelect="select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts";
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SQLServerProviders cls = new SQLServerProviders(connectionString);
            
            DataTable dataTable = cls.GetDataTable(querySelect, CommandType.Text, 0, maxRecord);
            querySelect = "select count(*) from tblRCAccounts";
            totalRecord = cls.GetOneValue(querySelect, CommandType.Text);
            DataList1.DataKeyField = "RecruiterID";
            DataList1.DataSource = dataTable;
            DataList1.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
    public int FillRecruiterAccount(Repeater repeater, int startRecord, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SQLServerProviders cls = new SQLServerProviders(connectionString);
            DataTable dataTable = cls.GetDataTable("select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts", CommandType.Text, startRecord, maxRecord);
            totalRecord = dataTable.Rows.Count;
             
            repeater.DataSource = dataTable;
            repeater.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
    public int FillRecruiterAccount(Repeater repeater, int maxRecord)
    {
        int totalRecord = 0;
        try
        {
            string querySelect = "select " +
            "RecruiterID, Email,CompanyName,"
            + "ContactName,  Address,Phone" +
            " from tblRCAccounts";
            string connectionString =
            WebConfigurationManager.ConnectionStrings[
                "RecruitVietnamDbConnectionString"
                ].ConnectionString;
            SQLServerProviders cls = new SQLServerProviders(connectionString);

            DataTable dataTable = cls.GetDataTable(querySelect, CommandType.Text, 0, maxRecord);
            querySelect = "select count(*) from tblRCAccounts";
            totalRecord = cls.GetOneValue(querySelect, CommandType.Text);

            repeater.DataSource = dataTable;
            repeater.DataBind();
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;
        }
        return totalRecord;
    }
}
